/*
 * lcd_169_st7789v2.h
 *
 *  Created on: Mar 20, 2025
 *      Author: QkLia
 */

/*
 * SPI interface: 	SPI1
 * SCK: 			A5
 * MOSI:			A7
 *
 * RES: 			A6
 * CS: 				A3
 * DC: 				A4
 * BL: 				B9
 *
 * */


#ifndef LCD_169_ST7789V2_H_
#define LCD_169_ST7789V2_H_

#include "main.h"

#define LCD_RES_OFF HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_SET);
#define LCD_RES_ON HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_RESET);

#define LCD_CS_OFF HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET);
#define LCD_CS_ON HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET);

#define LCD_DC_DATA HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_SET);
#define LCD_DC_CMD HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_RESET);

#define LCD_BL_ON HAL_GPIO_WritePin(LCD_BL_GPIO_Port, LCD_BL_Pin, GPIO_PIN_SET);
#define LCD_BL_OFF HAL_GPIO_WritePin(LCD_BL_GPIO_Port, LCD_BL_Pin, GPIO_PIN_RESET);

void lcd_write_cmd(uint8_t cmd);

void lcd_write_dat8(uint8_t dat);

void lcd_write_dat16(uint16_t dat);

void lcd_init();

void lcd_set_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);

void lcd_draw_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t* color_map);

#endif /* LCD_169_ST7789V2_H_ */
